package cn.wolfcode.domain;

import cn.wolfcode.util.NoticeEnum;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Getter
@Setter
public class Notice {
    private Long id;
    private String title;
    private Employee employee;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    private Integer grade;
    private Boolean status;
    private String content;
    private Boolean isRead;

    //已读人数
    private Integer noRead;
    //未读人数
    private Integer read;

    private Notice readNotice;

    public String findName() {
        if (grade != null) {
            return NoticeEnum.findName(grade);
        }
        return null;
    }

    public String toJSON() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("grade", grade);
        map.put("content", content);
        return JSON.toJSONString(map);
    }
}